It is a good idea to use the OOGLNew routines and their variants for allocating storage and OOGLFree for freeing it. See GEOM/include/ooglutil.h for details.
A good way to debug external modules is to run them stand-alone first, and examine the ascii stream which they produce to check for obvious problems. Or catch it this stream in a file, edit the file, and then read that into geomview to see if it's making reasonable pictures.
The Makefile mechanism illustrated in this example is quite complex. The basic structure is that the source code exists at the GEOM/src/bin level, but there are multiple object directories corresponding to possibly different architectures (in our case O.sgi is the one of interest). The parent Makefile then descends into that directory and does the heart of the make. All the Makefiles include global makefiles from GEOM/makefiles, which define many macros that you don't need to understand. The important ones are explained below. There is a file called Makedefs in the parent directory that defines the macros SRCS, OBJS, and TARGET, which you will need to set to the appropriate filenames. (The DISTFILES macro can be safely ignored.) The only change you should need to make to the Makefile in the parent directory is to set the GEOM variable to the appropriate directory, which is the top of the geomview tree. This change also should be made to O.sgi/Makefile, which you can then modify as appropriate for your application. Remember that after modifying any of the makefiles you should type
% make dependEnjoy.